<style type="text/css">
  .l_h_30 {
    line-height: 30px;
  }
  .fa-style{
    width: 16px;
    height: 16px;
  }
  .pad0 {
    padding: 0px;
  }
  .table-style {
    margin-bottom: 0px;
    border: 0px;
  }
</style>
<div class="bg-light lter b-b wrapper-md">
  <h1 class="m-n font-thin h3">事件一任务管理</h1>
</div>
<div class="panel panel-default">

  <div class="panel-body">
    <div class="row wrapper">
      <button class="btn btn-success pull-right" ng-click="addEvent()">添加事件</button>
    </div>

    <!-- 网速太慢,画圈等 -->
    <h3 class="text-center" ng-if="formData.loading">
      <i class="fa fa-spin fa-spinner hide show inline"></i> 努力加载中...
    </h3>

    <div class="panel-group">
      <!-- 标题部分, 事件信息展示 -->
      <div class="panel panel-default" ng-repeat="event in eventList">
        <div class="panel-heading">
          <h4 class="panel-title">
            <div class="clear">
              <a class="l_h_30" data-toggle="collapse" href=#{{$index}} ng-click="event.open = !event.open">
                <i class="fa-style fa " ng-class="{'fa-chevron-down': event.open, 'fa-chevron-right': !event.open}"/> 
                {{event.id}}
              </a>
              <span class="pull-right">
                <button type="button" class="btn btn-info btn-sm" ng-click="addTask(event)">添加任务</button>
                <button type="button" class="btn btn-info btn-sm" ng-click="edit(event)">编辑</button>
                <button type="button" class="btn btn-danger btn-sm" ng-click="delete(event.id, $index)">删除</button>
              </span>
            </div>
          </h4>
        </div>
        <!-- 展开空的内容部分, 任务列表 -->
        <div id={{$index}} class="panel-collapse collapse in">
          <div class="panel-body pad0">
            <table class="table table-striped table-bordered table-style">
              <thead>
                <tr>
                  <th class="col-md-1 text-center">任务标题</th>
                  <th class="col-md-1 text-center">数据库类型</th>
                  <th class="col-md-1 text-center">目标数据库</th>
                  <th class="col-md-1 text-center">目标表</th>
                  <th class="col-md-1 text-center">触发条件</th>
                  <th class="col-md-1 text-center"></th>
                </tr>
              </thead>
              <tbody>
                <tr ng-repeat="task in taskList | filter : {'event_id': event.id}">
                  <td>{{task.task_title}}</td>
                  <td class="text-center">{{task.to_datasource_type}}</td>
                  <td class="text-center">{{task.to_database}}</td>
                  <td class="text-center">{{task.to_table_name}}</td>
                  <td>{{task.oper_type}}</td>
                  <td class="text-center">
                    <button type="button" class="btn btn-info btn-xs" ng-click="editTask(task)">编辑</button>
                    <button type="button" class="btn btn-xs" ng-click="openANDstop(task)" 
                    ng-class="{'btn-success': task.del_flag == '1', 'btn-danger': task.del_flag == '0'}">
                      {{task.del_flag == '0' ? '停止' : '启用'}}
                    </button>
                    <button type="button" class="btn btn-danger btn-xs" ng-click="deleteTask(task.id, $index)">删除</button>
                  </td>
                </tr>
              </tbody>
            </table>
          </div>
        </div>

      </div>
    </div>

    
  </div>
</div>



